﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Kokomo.Mirror.CliMetadata.Signatures
{
	public class TypeSpecSignature : Signature
	{
		internal TypeSpecSignature(TypeSpec typeSpec)
		{
			if (typeSpec == null) throw new ArgumentNullException("typeSpec");
			this.typeSpec = typeSpec;
		}

		private TypeSpec typeSpec;

		public Type Resolve(
			CliModule module,
			bool throwOnError,
			Type[] genericTypeArgs,
			Type[] genericMethodArgs
			)
		{
			return this.typeSpec.ResolveType(
				module,
				throwOnError,
				genericTypeArgs,
				genericMethodArgs
				);
		}

		public override string ToString()
		{
			return this.typeSpec.ToString();
		}

		public override bool Equals(object obj)
		{
			TypeSpecSignature other = obj as TypeSpecSignature;
			if (other == null) return false;

			bool equals = object.Equals(this.typeSpec, other.typeSpec);
			return equals;
		}
	}
}
